package com.example.controller;

import java.util.HashMap;
import java.util.Map;
import org.springframework.amqp.rabbit.connection.Connection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.example.controller.vo.SendMsgVO;
import com.example.service.rabbit.RabbitMqSender;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.AMQP.BasicProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;


/**
 * @author eatfi
 */
@Slf4j
@RestController
@RequestMapping("/test")
public class TestController {
    
    @Autowired
    private RabbitMqSender rabbitMqSender;

    @PostMapping("/send-msg")
    public String sendMsg(@RequestBody SendMsgVO message) throws Exception {
        rabbitMqSender.send(message);
        return "success";
    }

    @PostMapping("/send-direct")
    public String sendDirect(@RequestBody SendMsgVO message) throws Exception {
        rabbitMqSender.sendToDirectExchange(message);
        return "success";
    }

}
